package com.gitee.magic.framework.head.utils;

import java.util.Collection;
import java.util.Map;

import com.gitee.magic.core.utils.StringUtils;
import com.gitee.magic.framework.head.exception.BusinessException;

/**
 * @author start
 */
public class Assert {
	
	public static void isTrue(Boolean test,String message) {
		if(test) {
			throw new BusinessException(message);
		}
	}
	
	public static void isFalse(Boolean test,String message) {
		if(!test) {
			throw new BusinessException(message);
		}
	}

	public static void isNull(Object o,String message) {
		if(o==null) {
			throw new BusinessException(message);
		}
	}

	public static void isNotNull(Object o,String message) {
		if(o!=null) {
			throw new BusinessException(message);
		}
	}
	
	public static void isEquals(Object obj,Object target,String message) {
		if(obj.equals(target)) {
			throw new BusinessException(message);
		}
	}
	
	public static void isNotEquals(Object obj,Object target,String message) {
		if(!obj.equals(target)) {
			throw new BusinessException(message);
		}
	}
	
	public static void isEmpty(String content,String message) {
		if(StringUtils.isEmpty(content)) {
			throw new BusinessException(message);
		}
	}
	
	public static void isEmpty(Collection<?> list,String message) {
		if(list==null||list.isEmpty()) {
			throw new BusinessException(message);
		}
	}
	
	public static void isEmpty(Map<?,?> map,String message) {
		if(map==null||map.isEmpty()) {
			throw new BusinessException(message);
		}
	}
	
}
